import React, { Component } from 'react';
/* 1 导入需要使用的组件*/
import { BrowserRouter as Router, Routes, Route } from "react-router-dom";
/* 2 导入需要添加的路由页面*/
import Movie from '../views/Movie'
import Detail from '../views/Detail'
/* 3 定义需要加载的路由在数组中 */
const routes = [
    {
        path: '/', 
        element: <Movie />
    },
    {
        path: '/detail', 
        element: <Detail />
    }
]
/* 4 定义函数将路由进行循环 */
function RouteView(){
    return (
        <Router>
            <Routes>
                {routes.map(item=>{
                    return (
                        <Route
                            key={item.path}
                            path={item.path}
                            element={item.element}>
                        </Route>
                    )
                })}
            </Routes>
        </Router>
    )
}
/* 5 将函数进行导出 */
export default RouteView;
